<template>
	<view class="find" >
		<view class="attention-content" v-for="(item,index) in notes" :key="index">
			<view class="attention-content-img" @click="as">
				<image :src="item.img" mode="aspectFit"></image>
			</view>
			<text class="attention-content-text" @click="as">{{item.theme}}</text>
			<view class="attention-content-user">
				<view class="attention-content-user-img">
					<image :src="item.userHead" mode="aspectFit" class="attention-content-user-img-image"></image>
					<text class="attention-content-user-text">{{item.userName}}</text>
				</view>
				<view class="attention-content-user-line" @click="discolor(index)" ref="redT">
					<image src="@/static/TestImg/img/message/aixin.png" mode="aspectFit"
						class="attention-content-user-img-image" v-if="item.selected"></image>
					<image src="@/static/TestImg/img/indexImg/love.png" mode="aspectFit"
						class="attention-content-user-img-image" v-else></image>
					<text>{{item.linkNum}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "find",
		data() {
			return {
				lastScrollTop:0,
				show:true,
				notes: [
					
				],
				location:null,
				latitude:null,
			};
		},
		onLoad(){
			 uni.getLocation({
			        type: 'wgs84', // 返回 GPS 坐标
			        success: (res) => {
			          console.log('获取位置信息成功', res);
			          this.location = res.longitude; // 将位置信息存储在 data 中的 location 变量中
					  this.latitude= res.latitude
			        },
			        fail: (err) => {
			          console.error('获取位置信息失败', err);
			          // 可以根据具体情况处理错误，比如提示用户重新授权或检查网络连接等
			        }
			      });
			this.request("/", "post", this.location).then(
				(res) => {
					console.log(res);
					
				}).catch((err) => {
				console.log(err);
			})
		},
		methods: {
			discolor(e) {
				this.notes[e].selected = !this.notes[e].selected;
				// this.nates[e].NoSelected = !this.nates[e].NoSelected;
				if (this.notes[e].selected == true) {
					this.notes[e].linkNum--;
				} else if (this.notes[e].selected == false) {
					this.notes[e].linkNum++;
				}
			},
			as() {
				uni.navigateTo({
					url: "/pages/index/viewAsText/viewAsText"
				})
			},
			onPageScroll(e){
				console.log(e);
				const currentScrollTop = e.scrollTop;
				if(currentScrollTop < this.lastScrollTop){
					this.show=false;
				}
				 this.lastScrollTop = currentScrollTop;
			}
		}
	}
</script>

<style>
	.find {
		width: 750rpx;
		display: flex;
		/* flex-direction: column; */
		/* justify-content: space-evenly; */
		flex-wrap: wrap;
	}
	.label{
		width: 100%;
		height: 60rpx;
		margin-top: 100rpx;
		display: flex;
		justify-content: space-evenly;
		align-items: center;
	}
	.attention-content {
		margin-top: 10rpx;
		width: 370rpx;
		height: 600rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		border-radius: 16rpx;
	}

	.attention-content-img {
		width: 100%;
		height: 470rpx;
		/* display: flex; */
		overflow: hidden;

	}

	.attention-content-img image {
		width: 100%;
		height: 100%;
		object-fit: cover;
		object-position: center;
	}

	.attention-content-text {
		font-size: 35rpx;
	}

	.attention-content-user {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.attention-content-user-img {
		display: flex;
		justify-content: space-evenly;
	}

	.attention-content-user-img-image {
		width: 45rpx;
		height: 45rpx;
		object-fit: cover;
		object-position: center;
	}

	.attention-content-user-line {
		display: flex;
		align-items: center;
	}
</style>